package thread;

import java.util.concurrent.TimeUnit;

/**
 * @description: 打断方法
 * @date 2020/1/9 14:12
 */
public class ThreadInterrupt {

    public static void main(String[] args) throws Exception {
        Thread  thread = new Thread(()->{
            try {
                TimeUnit.MINUTES.sleep(1);

                while (true) {
                    System.out.println("hello ");
                }
            } catch (Exception e) {
                System.out.println("Oh,i am be interrupted");
            }
        });
        thread.start();
        TimeUnit.MILLISECONDS.sleep(2);
        thread.interrupt();
    }


}
